﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using CANO.Data.DAOs.Calendar;
using CANO.Data.Helpers;

namespace CANO.WebSite.UserControls
{
	public partial class ucAgendaImprimir : System.Web.UI.UserControl
	{
		protected void Page_Load(object sender, EventArgs e)
		{
			int CurrentRolID = Convert.ToInt32(Session["CurrentRolID"]);
			int CurrentUserID = Convert.ToInt32(Session["CurrentUserID"]);
			calendarRepeater.ItemDataBound += new RepeaterItemEventHandler(calendarRepeater_ItemDataBound);
			if (CurrentRolID == Convert.ToInt32(Enums.Rol.Gerencial))
			{
				calendarRepeater.DataSource = new CalendarCompromisos().GetCalendarManger();
				calendarRepeater.DataBind();
			}
			if (CurrentRolID == Convert.ToInt32(Enums.Rol.Asistente))
			{
				calendarRepeater.DataSource = new CalendarCompromisos().GetCalendarAsistente(CurrentUserID);
				calendarRepeater.DataBind();
			}
			if (CurrentRolID == Convert.ToInt32(Enums.Rol.Broker))
			{
				calendarRepeater.DataSource = new CalendarCompromisos().GetCalendarBroker(CurrentUserID);
				calendarRepeater.DataBind();
			}
		}

		void calendarRepeater_ItemDataBound(object sender, RepeaterItemEventArgs e)
		{

			RepeaterItem item = e.Item;
			if ((item.ItemType == ListItemType.Item) ||
				(item.ItemType == ListItemType.AlternatingItem))
			{
				Repeater RepeterEvents = (Repeater)item.FindControl("DayEventsRepeater");

				Panel PanelSinCompromisos = (Panel)item.FindControl("pnlSinCompromisos");

				if (RepeterEvents.Controls.Count > 0)
					PanelSinCompromisos.Visible = false;
			}

		}
	}
}